package com.example.process;

import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author wangbin
 */
@RestController
public class ProcessController {

    @Resource
    private ProcessService processService;

    /**
     * 查看流程定义列表
     */
    @GetMapping("/listProcessDefinition")
    public List<Map<String, Object>> listProcessDefinition() {
        return processService.listProcessDefinition();
    }

    /**
     * 新建流程定义
     */
    @PostMapping("/insertProcessDefinition")
    public void insert() {
        processService.insertProcessDefinition();
    }

    @PostMapping("/testStartProcessByIdAndUserId/{userId}/{processDefinitionKey}")
    public Map<String, Object> testStartProcessByIdAndUserId(@PathVariable String userId, @PathVariable String processDefinitionKey) {
        return processService.testStartProcessByIdAndUserId(processDefinitionKey, userId);
    }

    @DeleteMapping("/deleteAllProcess")
    public void deleteAllProcess() {
        processService.deleteAllProcess();
    }
}
